import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class JumpApp extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _JumpAppState();
  }
}

class _JumpAppState extends State<JumpApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('跳转到外部应用'),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            RawMaterialButton(
                child: Text('跳转到浏览器'),
                onPressed: () async {
                  const url = 'https://www.baidu.com';
                  if (await canLaunch(url)) {
                    await launch(url);
                  } else {}
                }),
            RawMaterialButton(
                child: Text('跳转到电话'),
                onPressed: () async {
                  const url = 'tel:10086';
                  if (await canLaunch(url)) {
                    await launch(url);
                  } else {}
                }),
            //发送短息
            RawMaterialButton(
                child: Text('发送短信'),
                onPressed: () async {
                  const url = 'sms:10086';
                  if (await canLaunch(url)) {
                    await launch(url);
                  } else {}
                }),
            //打开华为应用市场
            RawMaterialButton(
                child: Text('打开华为应用市场'),
                onPressed: () async {
                  const url = 'market://details?id=com.baidu.searchbox';
                  if (await canLaunch(url)) {
                    await launch(url);
                  } else {}
                }),
          ],
        ),
      ),
    );
  }
}
